<script setup lang="ts">
import {useRouter, useRoute} from 'vue-router'
import type {FormInstance, FormRules, UploadInstance, UploadProps, UploadRawFile} from 'element-plus'
import {genFileId} from 'element-plus'
import {reactive, ref, h, computed} from 'vue'
import {Server} from '../../stores/ajax';
import {Delete, Download, Plus, ZoomIn} from '@element-plus/icons-vue'
import type {TableColumnCtx} from 'element-plus/es/components/table/src/table-column/defaults'
import type {ElTable} from 'element-plus'
import {Search} from '@element-plus/icons-vue'
import type {UploadFile} from 'element-plus'
let router = useRouter()
let searchKey = $ref('')
let select = $ref('2')
let searchResult = $ref([])
const handleSearchSubmit = async () => {
    router.push({path: `/bbs/search/${select == '1' ? 'user' : 'post'}/${searchKey}`})
    // console.log("???")
    // await Server.get(`/post/search_post?key=${searchKey}`).then(res => {
    //     if (res.data && res.data.code == 0) {
    //         console.log(res.data)
    //         searchResult = res.data.return
    //     }
    // })
}
</script>

<template>
    <el-input v-model="searchKey" placeholder="Please input"
        class="input-with-select"
        @keypress.enter="handleSearchSubmit">
        <template #prepend>
            <el-select v-model="select" style="width: 75px">
                <el-option label="用户" value="1" />
                <el-option label="帖子" value="2" />
                <!-- <el-option label="Tel" value="3" /> -->
            </el-select>
        </template>
        <template #append>
            <el-button :icon="Search"
                @click="handleSearchSubmit" />
        </template>
    </el-input>
    </template>

<style>
</style>
